package com.j3a.journal.model;

// Generated 21 oct. 2014 14:53:50 by Hibernate Tools 4.0.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Article generated by hbm2java
 */
@Entity
@Table( name = "article"
        , catalog = "journal" )
public class Article implements java.io.Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Integer           articleId;
    private Journaliste       journaliste;
    private Sujet             sujet;
    private String            articleContenu;
    private Set<Numero>       numeros          = new HashSet<Numero>( 0 );

    public Article() {
    }

    public Article( Journaliste journaliste, Sujet sujet ) {
        this.journaliste = journaliste;
        this.sujet = sujet;
    }

    public Article( Journaliste journaliste, Sujet sujet, String articleContenu, Set<Numero> numeros ) {
        this.journaliste = journaliste;
        this.sujet = sujet;
        this.articleContenu = articleContenu;
        this.numeros = numeros;
    }

    @Id
    @GeneratedValue( strategy = IDENTITY )
    @Column( name = "ARTICLE_ID", unique = true, nullable = false )
    public Integer getArticleId() {
        return this.articleId;
    }

    public void setArticleId( Integer articleId ) {
        this.articleId = articleId;
    }

    @ManyToOne( fetch = FetchType.LAZY )
    @JoinColumn( name = "JOURNALISTE_ID", nullable = false )
    public Journaliste getJournaliste() {
        return this.journaliste;
    }

    public void setJournaliste( Journaliste journaliste ) {
        this.journaliste = journaliste;
    }

    @ManyToOne( fetch = FetchType.LAZY )
    @JoinColumn( name = "SUJET_ID", nullable = false )
    public Sujet getSujet() {
        return this.sujet;
    }

    public void setSujet( Sujet sujet ) {
        this.sujet = sujet;
    }

    @Column( name = "ARTICLE_CONTENU", length = 600 )
    public String getArticleContenu() {
        return this.articleContenu;
    }

    public void setArticleContenu( String articleContenu ) {
        this.articleContenu = articleContenu;
    }

    @ManyToMany( fetch = FetchType.LAZY )
    @JoinTable( name = "article_numero", catalog = "journal", joinColumns = {
            @JoinColumn( name = "ARTICLE_ID", nullable = false, updatable = false ) }, inverseJoinColumns = {
            @JoinColumn( name = "NUMERO_ID", nullable = false, updatable = false ) } )
    public Set<Numero> getNumeros() {
        return this.numeros;
    }

    public void setNumeros( Set<Numero> numeros ) {
        this.numeros = numeros;
    }

}
